fix(cache): degrade safely when optional cache initialization fails#1890
Conversation
307a5d2 to
73f0beb
Compare
|
The |
…ss poisoning (OtterMind#1724) The static initializer only caught Exception, missing Errors like NoClassDefFoundError. Once the init failed with an Error, the class was permanently poisoned and cache was silently disabled. Also add init guard to fuzzyDelete() to prevent NPE when cache init failed and fuzzyDelete is called externally.
73f0beb to
c3bdc93
Compare
|
Fixed. Changed to , and added an guard at the beginning of to prevent accessing when cache is not initialized. |
|
Fixed. Changed |
openai0229
left a comment
There was a problem hiding this comment.
The narrowed Exception | LinkageError boundary is a better direction than catching all Throwable, but this still needs a focused regression test that forces cache initialization to fail and verifies the class remains usable in the intended degraded mode.
Please also coordinate with #1925: both PRs add the same fuzzyDelete initialization guard, so the duplicate change should live in only one focused PR. After resolving that overlap, update the branch with main and rerun the required checks.
openai0229
left a comment
There was a problem hiding this comment.
Re-reviewing the current head: this should not be merged without a current reproduction and focused test.
The failure reported in historical issue #1724 was an Ehcache StateTransitionException, which is already covered by the catch (Exception e) present on current main. This PR additionally catches every LinkageError and adds a degraded-mode guard, but it does not demonstrate a current 5.3.x failure that requires that broader boundary or test initialization failure behavior.
Issue #1724 has been closed as outdated, the branch is 54 commits behind main, and the fuzzyDelete guard overlaps #1925. I recommend closing this PR. A new change should start from a current-version reproduction, define which initialization failures are safe to degrade, and include a regression test.
openai0229
left a comment
There was a problem hiding this comment.
Maintainer follow-up completed. Optional cache initialization now has an explicit unavailable state, catches only Exception and LinkageError, preserves fatal Error propagation, and the fallback/lifecycle regression tests pass locally.
Related issue
Closes #1979
Summary
Makes optional disk-cache initialization a narrow, testable degradation boundary.
ExceptionorLinkageErrorproduce an explicit unavailable stateOutOfMemoryError,StackOverflowError, andThreadDeathremain visible to the runtimefuzzyDeleteandcloseare safe no-ops without a cache managerThe public static
CacheManageAPI remains unchanged. Cache path, capacity, expiry, and JSON serialization are also unchanged.Affected surfaces
Verification
mvn -pl chat2db-community-domain/chat2db-community-domain-core -am -Dtest=CacheManageTest -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.test.skip=false -DskipTests=false test- passed; 4 tests, 0 failures/errors/skipsgit diff --check origin/main...HEAD- passedRisk and compatibility
Reviewer map
CacheManage.CacheStore.initialize, thenCacheManageTest.Contributor declaration
AI assistance: OpenAI Codex assisted with the maintainer follow-up, regression tests, and verification; the resulting diff was reviewed locally.